//
//  main.m
//  Block的本质
//
//  Created by 崔博 on 2018/6/27.
//  Copyright © 2018年 崔博. All rights reserved.
//
typedef void(^Block)(void);
#import <Foundation/Foundation.h>
#import "Person.h"
int main(int argc, const char * argv[]) {
    @autoreleasepool{
    Person * p  = [Person new];
    p.block = ^{
        NSLog(@"%d---",p.age);
    };
    p.age = 10;
    }
    return 0;
}
void objecBlock(){
    Block block;
    {
        Person * p = [Person new];
        p.age = 10;
        block = ^{
            NSLog(@"%d",p.age);
        };
    }
    NSLog(@"11111");
}
void globalBlock(){
    /// global:没有访问auto变量
    void (^block)(void) = ^{
        NSLog(@"block1------");
    };
    int age = 10;
    void (^block1)(void) = ^{
        NSLog(@"block1------");
        age == 8;
    };
    NSLog(@"%@ %@",[block class],[block1 class]);
    
}

void block()
{
    void(^Block)(void) = ^() {
        int a = 10;
    };
    
    Block();
    NSLog(@"%@",[Block class]);
    NSLog(@"%@",[[Block class] superclass]);
    NSLog(@"%@",[[[Block class] superclass] superclass]);
    NSLog(@"%@",[[[[Block class] superclass] superclass] superclass]);
}
void typeBlock()
{
    void(^Block1)(void) = ^() {
        NSLog(@"hello");
    };
    int age = 10;
    void(^Block2)(void) = ^() {
        NSLog(@"hello--%ld",age);
    };
    NSLog(@"%@  %@  %@",[Block1 class],[Block2 class],[^{} class]);
}
